<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>

</body>
<script>
  "use strict"; {
    let arr = [1, 2, 2, 1, 1, 1, 3];
    const total = (item) => {
      return arr.reduce((pre, value, index, arr) => {
        return pre += item === value ? 1 : 0;
      }, 0);
    };
    console.log(total(1));

  };
</script>

</html>